package cn.ht.bootdemo.designmode.facAndmethod.factory;

import cn.ht.bootdemo.designmode.facAndmethod.service.UserPayService;
import org.springframework.util.Assert;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ht
 * @Description: 打折策略实现工厂
 * @date 2020-5-11
 */
public class UserServiceStrategyFactory {

    private static Map<String, UserPayService> services = new HashMap<>();

    public  static UserPayService getByUserType(String type){
        return services.get(type);
    }

    public static void register(String userType,UserPayService userPayService){
        Assert.notNull(userType,"没有该code对应的实现类！");
        services.put(userType,userPayService);
    }

}
